package goodbaby.dklt.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.classic.core.utils.DateUtil;

import java.util.List;

import goodbaby.dklt.R;
import goodbaby.dklt.bean.AttendanceBean;

/**
 * Created by Jayden on 2016/5/4 11:38.
 *
 * @version V1.0
 * @Title: AttendanceAdapter
 * @Description: 考勤适配器
 */
public class AttendanceAdapter extends BaseAdapter {
    private Context context;
    private List<AttendanceBean> data;

    public AttendanceAdapter(Context paramContext, List<AttendanceBean> paramList) {
        this.context = paramContext;
        this.data = paramList;
    }

    public int getCount() {
        return this.data.size();
    }

    public Object getItem(int paramInt) {
        return this.data.get(paramInt);
    }

    public long getItemId(int paramInt) {
        return paramInt;
    }

    public View getView(int paramInt, View paramView, ViewGroup paramViewGroup) {
        ViewHolder localViewHolder;
        if (paramView == null) {
            paramView = LayoutInflater.from(context).inflate(R.layout.item_attendance, null);
            localViewHolder = new ViewHolder();
            localViewHolder.tvDate = ((TextView) paramView.findViewById(R.id.item_tv_date));
            localViewHolder.tvWeek = ((TextView) paramView.findViewById(R.id.item_tv_week));
            localViewHolder.tvEnterTime = ((TextView) paramView.findViewById(R.id.item_tv_enter_time));
            localViewHolder.tvLeaveTime = ((TextView) paramView.findViewById(R.id.item_tv_leave_time));
            paramView.setTag(localViewHolder);
        } else {
            localViewHolder = (ViewHolder) paramView.getTag();
        }

        String str1 = data.get(paramInt).getCreatedOn();
        String str2 = DateUtil.getWeek(DateUtil.StringToDate(str1, "yyyy-MM-dd"));
//        String str3 = data.get(paramInt).getOneCreateOn_Time();
//        String str4 = data.get(paramInt).getTwoCreateOn_Time();
        localViewHolder.tvDate.setText(str1);
        localViewHolder.tvWeek.setText(str2);
//        localViewHolder.tvEnterTime.setText(str3);
//        localViewHolder.tvLeaveTime.setText(str4);

        return paramView;
    }

    class ViewHolder {
        TextView tvDate;
        TextView tvEnterTime;
        TextView tvLeaveTime;
        TextView tvWeek;
    }
}
